/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import java.util.*;

/**
 * Parsing XML File utilizando un unico Map para representar los valores
 * de los distintos tags del mismo
 *
 * @author Guillermo Cherencio
 */
public class HashHandleXMLFile extends DefaultHandler {

    private Map<String, String> map = new HashMap<String, String>();
//...
    public HashHandleXMLFile() {
        super();
    }

    public HashHandleXMLFile(Map<String, String> m) {
        super();
        map = m;
    }
// comienza tag
    @Override
    public void startElement(String uri, String localName, String qName,
            Attributes attributes) throws SAXException {
        System.out.println("uri=" + uri + " localName=" + localName + " qName=" + qName);
//...
    }
// termina tag
    @Override
    public void endElement(String uri, String localName,
            String qName) throws SAXException {
        System.out.println("End Element :" + qName);
//...
    }
// contenido del tag
    public void characters(char ch[], int start, int length) throws SAXException {
        String contenido_tag = new String(ch, start, length);
//...
    }

    public Map<String, String> getMap() {
        return map;
    }
}